-- local name = 'Aerial-'
-- for i=1,10,1 do
--     local groupName = name..i
--     local unit = Unit.getByName(groupName..'-1')
--     if unit then 
--         if not unit:isExist() then return end
--         if not unit:isActive() then return end
--         if unit:getLife() < 1 then return end


--         Utils.Debug(unit:getTypeName())
--         env.info('unit type: '..unit:getTypeName())
--     end
-- end

-- local ev = {}
-- function ev:onEvent(event)
--     if event.id == world.event.S_EVENT_DEAD then
--         local obj = event.initiator
--         local unit = obj:getUnit(1)
--         if not unit then return end
--         Utils.Debug('unit: '..unit:getName()..' lost')    
--     end
-- end
-- world.addEventHandler(ev)

-- local function test()
--     local group = Group.getByName('Aerial-1')
    
--     group:destroy()
--     deadevent = {
--         id = 8,
--         time = timer.getTime(),
--         initiator = group
--     }
--     world.onEvent(deadevent)
--     deadevent = nil
-- end
-- -- timer.scheduleFunction(test,nil,timer.getTime()+5)

-- local function threadTest(value)
--     for i=1,100,1 do
--         Utils.Debug(value..i,1)
--     end
-- end
-- timer.scheduleFunction(threadTest,'A',timer.getTime()+5)
-- timer.scheduleFunction(threadTest,'B',timer.getTime()+5)

-- local group = Group.getByName('Aerial-6')
-- if not group then return end

-- local unit = group:getUnit(1)
-- if not unit then return end

-- local PlaneSpeed = unit:getVelocity()
-- local PlanePos = unit:getPoint()
-- local WindSpeed = atmosphere.getWind(PlanePos)
-- local temperature, pressure = atmosphere.getTemperatureAndPressure(PlanePos)

-- local function mag(vec)
--     return (vec.x^2 + vec.y^2 + vec.z^2)^0.5
-- end

-- local TAS_Plane = mag(PlaneSpeed)*3600/1852
-- local TAS_Wind = mag(WindSpeed)*3600/1852

-- local R = 287
-- local rho0 = 1.225
-- local rho = pressure/(R * temperature)
-- local cas = TAS_Plane * math.sqrt(rho / rho0)

-- local msg = 'temperature: '..temperature..' pressure: '..pressure..'\n'..
--             'WindSpeed.x: '..WindSpeed.x..'WindSpeed.y: '..WindSpeed.y..'WindSpeed.z: '..WindSpeed.z..'\n'..
--             'TAS_Wind: '..TAS_Wind..' TAS_Plane: '..TAS_Plane..'\n'..
--             'CAS: '..cas
            
-- trigger.action.outText(msg,10)